package main

import (
	"fmt"
	"io/ioutil"
	global2 "longmen/server/config/global"
	"longmen/server/pkg/common/helper/blackWorlds/dfa"
	"strings"
	"time"
)

func main() {
	global2.Initialize("../app.properties")
	insertDB()
	t, _ := filter.filter.GetSensitiveWord().Filter("禁平")
	fmt.Println(t)
}

func insertDB() {
	filepath := "../blackWords.txt"
	fileData, err := ioutil.ReadFile(filepath)
	if err != nil {
		fmt.Printf("ReadFile err:%s \n", err.Error())
		return
	}
	data := strings.Split(string(fileData), ",")
	i := 0
	timeNow := time.Now().AddDate(0, 0, i).Format("2006-01-02 15:04:05")
	session := global2.GetX()

	for _, v := range data {
		sql := fmt.Sprintf("insert into db_black_keyword (keyword,add_time) value (\"%s\",\"%s\")", v, timeNow)
		err := session.Exec(sql).Error
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println("插入成功")
	}
}
